package com.exam.controller;

import com.exam.pojo.entity.ScoreStu;
import com.exam.pojo.entity.TestJoin;
import com.exam.pojo.entity.TestScore;
import com.exam.service.impl.TestJoinServicelmpl;
import com.exam.service.impl.TestScoreServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class TestScoreController {
    @Autowired
    TestScoreServiceImpl testScoreService;

    @RequestMapping( "test-score-student.html")
    public String testScoreList(Model model) {
        List<TestScore> testScoreList = testScoreService.findAll();
      /*  List<TestScore> allName = testScoreService.findAllName();*/
        List<TestScore> allName2 = testScoreService.findAllName2();
        System.out.println(testScoreList);
        model.addAttribute("testScoreList", testScoreList);
        /*model.addAttribute("allName", allName);*/
        model.addAttribute("allName2", allName2);

        return "test-score-student";
    }
    //条件查询
    @PostMapping("findTestScore")
    public String   selectStion(Model model,String examName,String score){
        System.out.println(examName);
        List<TestScore> testScoreList = testScoreService.findTestScore(examName, score);
       /* List<TestScore> allName = testScoreService.findAllName();*/
        List<TestScore> allName2 = testScoreService.findAllName2();
        System.out.println(testScoreList);
        model.addAttribute("testScoreList",testScoreList);
        /*model.addAttribute("allName", allName);*/
        model.addAttribute("allName2", allName2);
        return "test-score-student";
    }

}
